//
//  EInputViewController.m
//  Enote
//
//  Created by wangkejie on 2016/10/18.
//  Copyright © 2016年 Jack. All rights reserved.
//

#import "EInputViewController.h"


@interface EInputViewController ()<UITextViewDelegate>

@property (nonatomic, strong) UITextView * textView;

@end

@implementation EInputViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"便签";
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.textView = [[UITextView alloc] initWithFrame:CGRectMake(25, 15, SCREEN_WIDTH - 50, SCREEN_HEIGHT)];
    self.textView.font = [UIFont systemFontOfSize:17];
    self.textView.delegate = self;
//    self.textView.textColor = [UIColor ];
    self.textView.keyboardType = UIKeyboardTypeNamePhonePad;
    
    [self.view addSubview:self.textView];

    
    
}

- (void)viewWillDisappear:(BOOL)animated {

    [self contentSave];
}
- (void)contentSave {
    if (_isInput) {
        if (!_textView.text.length) {
            return;
        }
        NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
        
        Enote * e = [NSEntityDescription insertNewObjectForEntityForName:self.manage.coreDataModelName inManagedObjectContext:self.manage.context];
        e.content = self.textView.text;
        e.time = time;
        e.creatTimeOnly = time;
        e.state = 0;
        
        [[DataSourceManage sharedInstance] insertEnoteModel:e success:^{
            
        } fail:^(NSError *error) {
            
        }];
    }
}

@end
